package com.bjsxt.util;

import com.bjsxt.disruptor.Order;
import com.bjsxt.domain.EntrustOrder;

/**
 * @Description:
 * @ClassName: BeanUtil
 * @Author: chenyu
 * @Date: 2025/3/20 15:59
 */
public class BeanUtil {

    /**
     * 将EntrustOrder 转化为我们的Order
     * @param entrustOrder
     * @return
     */
    public static Order entrustOrder2Order(EntrustOrder entrustOrder) {
        Order order = new Order();
        order.setOrderId(entrustOrder.getId().toString());

        order.setPrice(entrustOrder.getPrice());
        order.setAmount(entrustOrder.getVolume().add(entrustOrder.getDeal().negate())); // 交易的数量= 总数量- 已经成交的数量

        order.setSymbol(entrustOrder.getSymbol());
        order.setOrderDirection(entrustOrder.getType().intValue());
        order.setTime(entrustOrder.getCreated().getTime());
        return order ;

    }
}
